<?php

/**
 * 微信帐号配置logic
 */

namespace Manage\Logic;

class WeixinLogic extends CommonLogic {
    
	//获取用户的微官网配置信息
	public function detail($uid = UID){
	    $map = array(
	        'uid'=>$uid
	    );
	    return $this->where($map)->find();
	}
	
	
	/**
	 * (non-PHPdoc)
	 * @see \Member\Logic\BaseLogic::update()
	 */
	public function update($data = array(),$map = array('uid'=>UID)){
		
		if(empty($data)){
			$data = $this->create();
		}
		
		if($data === false){
			return false;
		}
		
		$info = $this->isexists($map);
		
		/* 添加或更新数据 */
		if($info === false){//新增数据
			$data['uid'] = UID;
			$id = $this->add($data);
			if(!$id){
				$this->error = '新增详细内容失败！';
				return false;
			}
			return $id;
			
		} else { //更新数据
			$status = $this->where(array('id'=>$info['id']))->save($data);
			if(false === $status){
				$this->error = '更新详细内容失败！';
				return false;
			}
		}
		
		return true;
	}
	
	/**
	 * (non-PHPdoc)
	 * @see \Member\Logic\BaseLogic::autoSave()
	 */
	public function autoSave($id = 0){
		 
	}
}